﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace LibrarySystem
{
    public partial class AccountSettings : Form
    {
        string User;
        SqlConnection Connection_Main = new SqlConnection();
        //string str;
        AppManager LIB1 = new AppManager();
        public AccountSettings(string Name)
        {
            InitializeComponent();
            User = Name;
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void AccountSettings_Load(object sender, EventArgs e)
        {
            labelMessge.Text = "";
            label6.Text = User;
            LIB1.ComboDisplayChoose(comboBoxPASS_SHOE, "select * from alssafa.dbo.EMPLOYEE where الإسم = '" + label6.Text + "'", "EMPLOYEE", "كلمة_المرور", textBoxPASS_SHOE);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (PassWordOld.Text == textBoxPASS_SHOE.Text)
            {
                if (PassWordNew.Text.Length > 0)
                {
                    if (PassWordNew.Text == REPassWordNew.Text)
                    {

                        if ((MessageBox.Show("هل أنت متأكد من تغيير كلمة المرور؟", "تأكيد كلمة المرور", MessageBoxButtons.YesNo)) == System.Windows.Forms.DialogResult.Yes)
                        {
                            LIB1.update("UPDATE EMPLOYEE SET كلمة_المرور='" + REPassWordNew.Text + "' where الإسم='" + label6.Text + "'");
                            labelMessge.Text = "";
                            this.Close();
                        }

                    }
                    else
                        labelMessge.Text = "كلمتا المرور غير متطابقة";
                }
                else
                    labelMessge.Text = "أدخل كلمة المرور الجديدة";
            }
            else
                labelMessge.Text = "أدخل كلمة المرور الحالية";
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            if (PassWordOld.Text == textBoxPASS_SHOE.Text)
            {
                labelMessge.Text = "";
                

            }
            else
                labelMessge.Text = "كلمة المرور غير صحيحة";
        }
    }
}
